<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class TaskTemplate extends Model
{
    use HasFactory, SoftDeletes;

    const STATUS_OFF = 0;
    const STATUS_ON = 1;

    protected $casts = [
        'attachment' => 'json',
    ];

    protected $fillable = ['name', 'frequency', 'sheet_template_id', 'description', 'attachment'];

    protected $hidden = ['deleted_at'];

    public function sheetTemplate()
    {
        return $this->belongsTo(SheetTemplate::class)->select('id', 'name');
    }

    public function tasks()
    {
        return $this->hasMany(Task::class);
    }
}
